- content_for(:title, 'Remote Deployment Targets')
- content_for(:body_id, 'deployments_flow')
= render '/shared/breadcrumbs', breadcrumbs: ['Manage', yield(:title)]
%script#job_template{type: 'text/x-handlebars-template'}
  = render 'job', { presenter: JsonJobPresenter.new(self) }
%script#journal_line_template{type: 'text/x-handlebars-template'}
  %p
    %span.timestamp {{timestamp}}
    %span.source {{source}}
    {{message}}

- @jobs.each do |job|
  - presenter = JobPresenter.new(job, self)
  .deployment-job{ class: "initially-#{presenter.status}", id: "#{presenter.dom_id}" }
    .deployment-job-progress{ data: { source: job_path(job.key) } }
      = render 'job', presenter: presenter
    - if presenter.documentation.present?
      .deployment-job-documentation
        %h5 Documentation
        != presenter.documentation
    .deployment-job-log
      %code.log-output{ data: { source: log_job_path(job.key) } }
        - job.log.each do |output|
          %p= output

= render @deployment_targets

- if @jobs.empty? && @deployment_targets.to_a.empty?
  %p.macrocopy
    A Remote Deployment Target allows you to use Panamax to deploy templates and images to your infrastructure.
    You can setup your target manually and register it with Panamax via a token, or via Dray, leveraging popular cloud providers and orchestrators.
    %br/
    = link_to 'Learn more about Remote Deployment Targets.', 'https://github.com/CenturyLinkLabs/panamax-ui/wiki/Panamax-Remote-Agent-Installation', target: '_blank'
    %br/
    = link_to 'Learn more about Dray.', 'https://registry.hub.docker.com/u/centurylink/dray/', target: '_blank'

= render 'shared/errors', errors: @deployment_target.errors
= form_for @deployment_target, html: { id: 'create_target', class: ('expanded' unless @deployment_target.valid?) } do |f|
  %dl
    %dt= f.label :name
    %dd= f.text_field :name
    %dt= f.label :auth_blob, 'Token'
    %dd= f.text_area :auth_blob

  = f.button 'Save Remote Deployment Target', class: 'button-add-positive'
  %a.button-cancel{ { data: { toggle: { target: '#create_target', class: 'expanded' }, cancel: { form: true } } } }
    Cancel

.add-target
  %h2 Add a Remote Deployment Target
  .providers
    %p.macrocopy
      Automatically set up your deployment target on one of these providers using
      = link_to 'Dray.', 'https://registry.hub.docker.com/u/centurylink/dray/', target: '_blank'

    %ul
      - @job_templates_by_vendor.each do |vendor, templates|
        %li.provider
          %span= provider_label(vendor)
          .job-templates
            %h6 Select Orchestrator
            - templates.each do |job_template|
              = link_to job_template.adapter, new_job_path(template_id: job_template.id), title: job_template.name

    %p.alternative-provider
      Don't see your favorite provider listed?
      %br/
      Set a deployment target up manually.
      = link_to 'Learn more.', 'https://github.com/CenturyLinkLabs/panamax-ui/wiki/Panamax-Remote-Agent-Installation', target: '_blank'
  %p
    Already have a deployment target set up?
    %br/
    %a{ { data: { toggle: { target: '#create_target', class: 'expanded' } } } } Enter your token here.
